package com.bolt.admin.module.sys.entity;

import com.bolt.support.spring.jpa.entity.BaseUuidEntity;
import lombok.Data;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;


@Access(AccessType.FIELD)
@Entity
@Table(name = "SYS_USER2ROLE", uniqueConstraints = @UniqueConstraint(columnNames = {"user_id", "role_id"}))
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Data
public class UserR2Role extends BaseUuidEntity {

    private static final long serialVersionUID = -1727859177925448384L;

    @ManyToOne
    @JoinColumn(name = "user_id", nullable = false)
    private UserEntity user;

    @ManyToOne
    @JoinColumn(name = "role_id", nullable = false)
    private RoleEntity role;

    @Column(name = "user_id", length = 36, updatable = false, insertable = false)
    private String userId;

    @Column(name = "role_id", length = 36, updatable = false, insertable = false)
    private String roleId;




}
